<template >
<div>
    <yd-cell-group class="mt30" title="设备登录">
        <yd-cell-item>
            <span slot="left">用户名：</span>
            <yd-input slot="right" required v-model="form.username" max="20" placeholder="请输入设备编号"></yd-input>
        </yd-cell-item>
        <yd-cell-item>
            <span slot="left">密码：</span>
            <yd-input slot="right" type="password" v-model="form.password" placeholder="请输入密码"></yd-input>
        </yd-cell-item>
    </yd-cell-group>

    <yd-button size="large" type="primary" @click.native="gogo">登录</yd-button>

</div>
</template>

<script>

import { mapGetters } from 'vuex'
import { setCookie, getCookie} from '../../util/util'

export default {
	
	name : 'destorylogin',
	
	data () {
		return {
		  	form : {
		  		username : '',
		  		password : '',
		  	}
		}
	},

	props : {

	},

	components : {
		
	},

	computed : {
		...mapGetters([
			
		]),
	},

	methods : {
		gogo () {
			let para = {
				fun : 'destroyLogin',
				device : this.form.username,
				password : this.form.password,
				cb : res => {
					console.log(res);

					setCookie('dusername', this.form.username);
					setCookie('dpassword', this.form.password);

					this.$router.push({ 
						'name': 'destroymain', 
						'query' : {
			    			'name' : res.name,
			    			'devicecode' : this.form.username,
			    		}
					});

				},
				err : res => {
					console.log('error');
					console.log(res);
					this.$message.error(res);
				}
			};

			this.$store.dispatch('update', para);
		},
	},

	watch : {
	    
	},

	mounted () {
		this.form.username = getCookie('dusername');
		this.form.password = getCookie('dpassword');
	},

}
</script>

<style scoped>
.image {
	width: 100%;
}
</style>
